/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"8105E0EF-D433-4E76-A8C9-F139868D0F85",variableType:4}
 */
var fAnio = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"48BA176F-80CB-4027-A103-4A13639C050D",variableType:4}
 */
var fMes = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"56C23AE5-33A7-488E-9848-E368D121C27C",variableType:4}
 */
var fperiodo = null;

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"07F15C21-D44A-4496-9D90-A91B56ED176D"}
 * @AllowToRunInFind
 */
function onAction_consulta(event) {
	var estado = controller.find()
	if (estado == false)
	{
    	globals.DIALOGS.showWarningDialog("Aviso","Error al hacer el find","Ok")
		return
	}	
	var cuantos = controller.search()
	if (cuantos == 0){
    	globals.DIALOGS.showWarningDialog("Aviso","Sin Asientos en dicho mes","Ok")
		return
	}
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"C38F1100-749A-4934-AC43-4513EBD78FDD"}
 * @AllowToRunInFind
 */
function onShow(firstShow, event) {
	globals.gvarios = 3
	controller.loadRecords(null)
	databaseManager.setAutoSave(false)
	foundset.multiSelect = true
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"81EFDD4D-3300-4850-8F6E-B5B232E662D5"}
 * @AllowToRunInFind
 */
function imprimir(event) {
/*	antes_imp()
	forms.limbo_impresion.controller.showPrintPreview()*/
	jasper('impresion')
}

/**
 * @param {String} tipo
 * @properties={typeid:24,uuid:"5193AEE2-A1BE-4A1F-9DF4-E18EF4BD06F0"}
 */
function jasper(tipo)
{
	var $cols 	= new Array('limbo_to_limbo_cab.numero','limbo_to_limbo_cab.fecha','cuenta_impresion','leyenda','division','centro','importe_debe','importe_haber','limbo_to_limbo_cab.texto')
	var $ds 	= databaseManager.convertToDataSet( limbo_cab_to_limbo, $cols)
	$ds.setColumnName(1,'numero')
	$ds.setColumnName(2,'fecha')
	$ds.setColumnName(9,'texto_cab')
		
	var $params = {
		userv: usuarios_to_uservs.razon_social
	}
	
	globals.metodoJasper(tipo,'contable/asiento.jasper','Asiento_N_'+ numero,$ds,$params)	
}

/**
 * @AllowToRunInFind
 *
 * @properties={typeid:24,uuid:"93ABCD89-0061-4E66-AAA4-0A406208F190"}
 */
function antes_imp()
{
	var $elegidos = foundset.getSelectedIndexes()
	
	forms.limbo_impresion.controller.find()
	for ( var i = 0 ; i < $elegidos.length ; i ++)
	{
		foundset.setSelectedIndex($elegidos[i])
		if (i != 0)
		{
			forms.limbo_impresion.controller.newRecord()
		}
		forms.limbo_impresion.limbo_cab_id = foundset.limbo_cab_id
	}
	if (forms.limbo_impresion.controller.search() == 0)
		globals.DIALOGS.showWarningDialog("Aviso",'No hay movimientos','OK')
	else
	{
		var $frm = solutionModel.getForm('limbo_impresion')
		var tot_debe_p = $frm.getField('total_debe_p')
		var tot_hab_p = $frm.getField('total_haber_p')
		var tot_debe_d = $frm.getField('total_debe_d')
		var tot_hab_d = $frm.getField('total_haber_d')
		
		if (globals.gmoneda_consulta == 1)
		{
			tot_debe_p.printable	= true
			tot_hab_p.printable 	= true
			tot_debe_d.printable 	= false
			tot_hab_d.printable		= false
		}
		else
		{
			tot_debe_p.printable	= false
			tot_hab_p.printable 	= false
			tot_debe_d.printable	= true
			tot_hab_d.printable	 	= true
		}
		
		forms.limbo_impresion.controller.recreateUI()
		forms.limbo_impresion.controller.sort('limbo_cab_id asc , columna asc')
	}
}

/**
 * @properties={typeid:24,uuid:"FC21534D-D471-43BB-97B2-2F94F37C8029"}
 */
function pdf()
{
/*	antes_imp()
	globals.metodoPdf('limbo_impresion','asientos - '+globals.glegajo,true)*/
	jasper('pdf')
}

/**
 * @properties={typeid:24,uuid:"B8F437AD-D0AF-4B4F-B906-39DCA0CC313B"}
 */
function xls()
{
	jasper('xls')
}

/**
 * @properties={typeid:24,uuid:"5856B373-9043-4B56-8916-C43708A6498A"}
 */
function csv()
{
	jasper ('csv')
}